<?php
defined('_JEXEC') or die;

class KetnoiControllerEngine extends JControllerLegacy
{
	public function save()
	{
		$model = $this->getModel("Engine");
		$result = $model->save();
		$isQuickCreate = $this->input->getBool("quickcreate");
		if(!$result["success"] || $isQuickCreate)
		{
			echo json_encode($result);
			exit();
		}
		$id = $result["id"];
		JRequest::setVar("id",$id);	
		parent::display();
	}
	
	function save_engine_linhkien()
	{
		$model = $this->getModel("Engine");
		$result = $model->save_engine_linhkien();
		echo json_encode($result);
		exit();
	}
	
	public function checkTenExists()
	{
		$model = $this->getModel("Engine");
		$is_Exists = $model->checkTenExists();
		$str = "true";
		if($is_Exists)
		{
			$str = "false";
			
		}
		echo $str;
		exit();
	}
	
	public function checkMaExists()
	{		
		$model = $this->getModel("Engine");
		$is_Exists = $model->checkMaExists();
		$str = "true";
		if($is_Exists)
		{
			$str = "false";
			
		}
		echo $str;
		exit();
	}
	
	function delete()
	{
		$model = $this->getModel("Engine");
		$model->delete();
		echo true;
		exit();
	}
}
